package com.ruoyi.project.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.mapper.SysAlarmMapper;
import com.ruoyi.project.system.domain.SysAlarm;
import com.ruoyi.project.system.service.ISysAlarmService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 报警记录Service业务层处理
 * 
 * @author jjp
 * @date 2020-03-30
 */
@Service
public class SysAlarmServiceImpl implements ISysAlarmService 
{
    @Autowired
    private SysAlarmMapper sysAlarmMapper;

    /**
     * 查询报警记录
     *
     * 三表联查
     */
    @Override
    @Transactional
    public List<SysAlarm> selectSysAlarmById(String userId,String alarmType,String read)
    {
        if(null==read){
            sysAlarmMapper.updateRead(userId,alarmType);
        }
        return sysAlarmMapper.selectSysAlarmById(userId,alarmType,read);
    }

    /**
     * 查询报警记录列表
     * 
     * @param sysAlarm 报警记录
     * @return 报警记录
     */
    @Override
    public List<SysAlarm> selectSysAlarmList(SysAlarm sysAlarm)
    {
        return sysAlarmMapper.selectSysAlarmList(sysAlarm);
    }

    /**
     * 新增报警记录
     * 
     * @param sysAlarm 报警记录
     * @return 结果
     */
    @Override
    public int insertSysAlarm(SysAlarm sysAlarm)
    {
        sysAlarm.setCreateTime(DateUtils.getNowDate());
        return sysAlarmMapper.insertSysAlarm(sysAlarm);
    }

    /**
     * 修改报警记录
     * 
     * @param sysAlarm 报警记录
     * @return 结果
     */
    @Override
    public int updateSysAlarm(SysAlarm sysAlarm)
    {
        return sysAlarmMapper.updateSysAlarm(sysAlarm);
    }

    /**
     * 批量删除报警记录
     * 
     * @param alarmIds 需要删除的报警记录ID
     * @return 结果
     */
    @Override
    public int deleteSysAlarmByIds(Long[] alarmIds)
    {
        return sysAlarmMapper.deleteSysAlarmByIds(alarmIds);
    }

    /**
     * 删除报警记录信息
     * 
     * @param alarmId 报警记录ID
     * @return 结果
     */
    @Override
    public int deleteSysAlarmById(Long alarmId)
    {
        return sysAlarmMapper.deleteSysAlarmById(alarmId);
    }
}
